/**
 * 路由配置
 * @author Zeon scplay@gmail.com
 * @date 2017/8/2
 * @copyright Created by Panxsoft.
 */
import VueRouter from 'vue-router';
import { $t } from 'src/i18n';

import handleRouter from './handleRouter';


const routers = [
	{
		path: '/login',
		name: 'login',
		meta: {
			title: $t('routers.login'),
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/login/admin-views.vue')), 'admin-login');
		},
	},
	{
		path: '*',
		redirect: { name: 'login' },
	},
	// {
	// 	path: '/cust-login',
	// 	name: 'cust-login',
	// 	meta: {
	// 		title: $t('routers.customer_login'), // '客户登录',
	// 	},
	// 	component(resolve) {
	// 		return require.ensure([], () => resolve(require('./views/login/customer-views.vue')), 'cust-login');
	// 	},
	// },
	// {
	// 	path: '/store-login',
	// 	name: 'store-login',
	// 	meta: {
	// 		title: $t('routers.store_login'), // '店铺登录',
	// 	},
	// 	component(resolve) {
	// 		return require.ensure([], () => resolve(require('./views/login/store-views.vue')), 'store-login');
	// 	},
	// },
	{
		path: '/reset-password',
		name: 'reset',
		meta: {
			title: $t('routers.reset_password'), // '重置密码',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/reset-password/views.vue')), 'reset');
		},
	},
	// 公用的后台首页
	{
		path: '/mirror',
		meta: {
			title: $t('routers.mirror_home'), // ''后台首页',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/index.vue')), 'mirror-views');
		},
		children: [
			// 首页
			{
				path: '/',
				// name: 'mirror-home',
				// meta: {
				// 	title: $t('routers.mirror_home'), // 后台首页,
				// },
				// component(resolve) {
				// 	return require.ensure([], () => resolve(require('./views/home/index.vue')), 'mirror-home');
				// },
				redirect: { name: 'login' },
			},
			// admin权限下的路由
			{
				path: '/admin',
				name: 'admin-views',
				meta: {
					title: `${$t('routers.admin_home')} - ${$t('routers.admin')}`, // 超管后台首页,
					menu: $t('routers.admin_home'),
				},
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/admin/views.vue')), 'admin-views');
				},
				children: [
					{
						path: '/',
						// meta: {
						// 	title: `${$t('routers.mirror_home')}`, // 后台首页,
						// 	menu: $t('routers.mirror_home'),
						// },
						// component(resolve) {
						// 	return require.ensure([], () => resolve(require('./views/admin/home/views.vue')), 'mirror-admin-home');
						// },
					    redirect: { name: 'admin-device-management' },
					},
					// {
					// 	path: '/home',
					// 	meta: {
					// 		title: `${$t('routers.mirror_home')}`, // 后台首页,
					// 		menu: $t('routers.mirror_home'),
					// 	},
					// 	component(resolve) {
					// 		return require.ensure([], () => resolve(require('./views/admin/home/views.vue')), 'mirror-admin-home');
					// 	},
					// },
					// {
					// 	path: 'customer',
					// 	name: 'admin-customer',
					// 	meta: {
					// 		title: `${$t('routers.customer_management')} - ${$t('routers.admin')}`, // '客户管理',
					// 		menu: $t('routers.customer_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/customer/views.vue')), 'customer'),
					// },
					// {
					// 	path: 'staff',
					// 	name: 'admin-staff',
					// 	meta: {
					// 		title: `${$t('routers.staff_management')} - ${$t('routers.admin')}`, // '职员管理',
					// 		menu: $t('routers.staff_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/staff/views.vue')), 'staff'),
					// },
					// {
					// 	path: 'product',
					// 	name: 'admin-product',
					// 	meta: {
					// 		title: `${$t('routers.product_list')} - ${$t('routers.admin')}`, // '产品列表'
					// 		menu: $t('routers.product_list'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/views.vue')), 'product'),
					// },
					// {
					// 	path: 'product-category',
					// 	name: 'admin-product-category',
					// 	meta: {
					// 		title: `${$t('routers.product_category')} - ${$t('routers.admin')}`, // '产品分类'
					// 		menu: $t('routers.product_category'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/category/views.vue')), 'product-category'),
					// },
					// {
					// 	path: 'product-brand',
					// 	name: 'admin-product-brand',
					// 	meta: {
					// 		title: `${$t('routers.product_brand')} - ${$t('routers.admin')}`, // '产品品牌'
					// 		menu: $t('routers.product_brand'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/brand/views.vue')), 'admin-product-brand'),
					// },
					// {
					// 	path: 'product-model',
					// 	name: 'product-model',
					// 	meta: {
					// 		title: `${$t('routers.product_model')} - ${$t('routers.admin')}`, // '产品模型',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/model/views.vue')), 'product-model'),
					// },
					// {
					// 	path: 'product-specification',
					// 	name: 'product-specification',
					// 	meta: {
					// 		title: `${$t('routers.product_spec')} - ${$t('routers.admin')}`, // '产品规格',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/specification/views.vue')), 'product-specification'),
					// },
					// {
					// 	path: 'product-attribute',
					// 	name: 'product-attribute',
					// 	meta: {
					// 		title: `${$t('routers.product_attribute')} - ${$t('routers.admin')}`, // '产品属性',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/attribute/views.vue')), 'product-attribute'),
					// },
					// {
					// 	path: 'product-tag',
					// 	name: 'product-tag',
					// 	meta: {
					// 		title: `${$t('routers.product_tag')} - ${$t('routers.admin')}`, // '产品标签'
					// 		menu: $t('routers.product_tag'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/tag/views.vue')), 'product-tag'),
					// },
					{
						path: 'device-management',
						name: 'admin-device-management',
						meta: {
							title: `${$t('routers.device_management')} - ${$t('routers.admin')}`, // '设备管理'
							menu: $t('routers.device_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/device-management/views.vue')), 'device-management'),
					},
					{
						path: 'manufacturer_management',
						name: 'admin-manufacturer_management',
						meta: {
							title: `${$t('routers.manufacturer_management')} - ${$t('routers.admin')}`, // '制造商管理'
							menu: $t('routers.manufacturer_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/manufacturer_management/views.vue')), 'manufacturer_management'),
					},
					{
						path: 'announcement_management',
						name: 'admin-announcement_management',
						meta: {
							title: `${$t('routers.announcement_management')} - ${$t('routers.admin')}`, // '公告管理'
							menu: $t('routers.announcement_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/announcement_management/views.vue')), 'announcement_management'),
					},
					{
						path: 'lighting_preset_management',
						name: 'admin-lighting_preset_management',
						meta: {
							title: `${$t('routers.lighting_preset_management')} - ${$t('routers.admin')}`, // '灯光预设管理'
							menu: $t('routers.lighting_preset_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/lighting_preset_management/views.vue')), 'lighting_preset_management'),
					},
					{
						path: 'advert',
						name: 'admin-advert',
						meta: {
							title: `${$t('routers.advert')} - ${$t('routers.admin')}`, // '广告管理'
							menu: $t('routers.advert'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/advert/views.vue')), 'advert'),
					},
					{
						path: 'get-applist',
						name: 'admin-get-applist',
						meta: {
							title: `${$t('routers.get_app_list')} - ${$t('routers.admin')}`, // '广告管理'
							menu: $t('routers.get_app_list'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/get-applist/views.vue')), 'get-applist'),
					},
					// {
					// 	path: 'machine-parameters',
					// 	name: 'machine-parameters',
					// 	meta: {
					// 		title: `${$t('routers.machine_parameters_management')} - ${$t('routers.admin')}`, // 机器试妆参数管理
					// 		menu: $t('routers.machine_parameters_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/machine-parameters/views.vue')), 'machine-parameters'),
					// },
					// {
					// 	path: 'supplies-management',
					// 	name: 'supplies-management',
					// 	meta: {
					// 		title: `${$t('routers.supplies_management')} - ${$t('routers.admin')}`, // 物资管理
					// 		menu: $t('routers.supplies_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/supplies/views.vue')), 'supplies-management'),
					// },
					// {
					// 	path: 'activity-management',
					// 	name: 'activity-management',
					// 	meta: {
					// 		title: `${$t('routers.activity_management')} - ${$t('routers.admin')}`, // 活动管理
					// 		menu: $t('routers.activity_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/activity/views.vue')), 'activity-management'),
					// },
					// {
					// 	path: 'test-product-label',
					// 	name: 'test-product-label',
					// 	meta: {
					// 		title: `${$t('routers.product_label_management')} - ${$t('routers.admin')}`, // 检测项关联产品标签的管理
					// 		menu: $t('routers.product_label_management'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/test-product-label/views.vue')), 'test-product-label'),
					// },
					// {
					// 	path: 'operate-log',
					// 	name: 'operate-log',
					// 	meta: {
					// 		title: `${$t('menus.operate_log')} - ${$t('routers.admin')}`, // 操作日志
					// 		menu: $t('menus.operate_log'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/operate-log/views.vue')), 'operate-log'),
					// },
					// {
					// 	path: 'account-overview',
					// 	name: 'account-overview',
					// 	meta: {
					// 		title: `${$t('menus.account_overview')} - ${$t('routers.admin')}`, // 账号总览
					// 		menu: $t('menus.account_overview'),
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/equipment/account-overview/views.vue')), 'account-overview'),
					// },
				],
			},
			// customer权限下的路由

			// 本地测试路由
			// {
			// 	path: '/v-debug',
			// 	component(resolve) {
			// 		return require.ensure([], () => resolve(require('./views/debug/index.vue')), 'debug-index');
			// 	},
			// 	children: [
			// 		{
			// 			path: '/',
			// 			name: 'debug',
			// 			meta: {
			// 				title: 'debug测试',
			// 			},
			// 			component: resolve => require.ensure([], () => resolve(require('./views/debug/vuex.vue')), 'debug-vuex'),
			// 		},
			// 		{
			// 			path: 'example',
			// 			meta: {
			// 				title: 'example测试',
			// 			},
			// 			component: resolve => require.ensure([], () => resolve(require('./views/debug/example.vue')), 'example'),
			// 		},
			// 	],
			// },
		],
	},
	// {
	// 	path: '/authorize-status',
	// 	name: 'authorize-status',
	// 	meta: {
	// 		title: $t('routers.auth_info'),	// 授权成功
	// 	},
	// 	component(resolve) {
	// 		return require.ensure([], () => resolve(require('./views/component/authorize-status.vue')), 'authorize-status');
	// 	},
	// },
	// {
	// 	path: '*',
	// 	redirect: { name: 'admin-device-management' },
	// },
];

// 路由配置
const RouterConfig = {
	// mode: 'history',
	mode: 'hash',
	routes: routers,
};

const router = new VueRouter(RouterConfig);

router.beforeEach(handleRouter.before);
router.afterEach(handleRouter.after);

export default router;
